<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增区域信息（省市县）')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-areas-add">
            <div class="form-group">    
                <label class="col-sm-3 control-label">父级d：</label>
                <div class="col-sm-8">
                    <div class="input-group">
                        <input id="treeId" name="parentId" type="hidden" th:value="${sysAreas?.areaId}"/>
                        <input class="form-control" type="text" onclick="selectAreasTree()" id="treeName" readonly="true" th:value="${sysAreas?.areaName}" required>
                        <span class="input-group-addon"><i class="fa fa-search"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">简称：</label>
                <div class="col-sm-8">
                    <input name="shortName" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">区域名称：</label>
                <div class="col-sm-8">
                    <input name="areaName" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">完整区域名称：</label>
                <div class="col-sm-8">
                    <input name="fullName" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">标识路径：</label>
                <div class="col-sm-8">
                    <input name="idPath" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">国家:中国86：</label>
                <div class="col-sm-8">
                    <input name="countryId" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">分区标识：</label>
                <div class="col-sm-8">
                    <input name="zoneId" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">省级id：</label>
                <div class="col-sm-8">
                    <input name="provinceId" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">市级id：</label>
                <div class="col-sm-8">
                    <input name="cityId" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">县或区域id：</label>
                <div class="col-sm-8">
                    <input name="districtId" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">区域层级：1省2市3县4乡：</label>
                <div class="col-sm-8">
                    <input name="areaLevel" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">首字母：</label>
                <div class="col-sm-8">
                    <input name="initials" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">同级排序编号：</label>
                <div class="col-sm-8">
                    <input name="orderNum" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">邮编：</label>
                <div class="col-sm-8">
                    <input name="zipCode" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">状态：</label>
                <div class="col-sm-8">
                    <select name="stateId" class="form-control m-b" th:with="type=${@dict.getType('sys_state_id')}" required>
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <textarea name="memo" class="form-control"></textarea>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script type="text/javascript">
        var prefix = ctx + "system/areas"
        $("#form-areas-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-areas-add').serialize());
            }
        }

        /*区域信息（省市县）-新增-选择父部门树*/
        function selectAreasTree() {
            var options = {
                title: '区域信息（省市县）选择',
                width: "380",
                url: prefix + "/selectAreasTree/" + $("#treeId").val(),
                callBack: doSubmit
            };
            $.modal.openOptions(options);
        }

        function doSubmit(index, layero){
            var body = layer.getChildFrame('body', index);
               $("#treeId").val(body.find('#treeId').val());
               $("#treeName").val(body.find('#treeName').val());
               layer.close(index);
        }
    </script>
</body>
</html>